package com.qm.service;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;


import com.qm.dao.UsersDAO;
import com.qm.model.ImportExcelReprotModel;
import com.qm.model.Score;
import com.qm.model.Topic;
import com.qm.model.TopicTest;
import com.qm.model.Users;
import com.qm.model.UsersClass;
import com.qm.util.*;

@Service
public class UserService{
	@Autowired
	@Qualifier("usersDao")
	private UsersDAO  udao;
	public UsersDAO getUdao() {
		return udao;
	}
	public void setUdao(UsersDAO udao) {
		this.udao = udao;
	}
	
	/**
	 * 在线考试，题目读取
	 * @param tcourseCode
	 * @return
	 */
	public ArrayList<TopicTest> onlineExam(int tcourseCode){
		ArrayList<Topic> tpList=udao.onlineExam(tcourseCode);
		ArrayList<TopicTest> tsList=new ArrayList<>();
		for (Topic topic : tpList) {
			tsList.add(new TopicTest(topic));
		}
		return tsList;
	
	}
	/**
	 * 根据学生ID来查询学生成绩
	 * @param unumber
	 * @return
	 */
	public ArrayList<Score> selectScoreByUid(int uid){
		ArrayList<Score> result=udao.selectScoreByUid(uid);
		return result;
		
	}
	/**
	 * 插入学生成绩
	 * @param uc
	 * @return
	 */
	public int insertScoreByUid(UsersClass uc){
		int result= udao.insertScoreByUid(uc);
		return result;
	}
 }
